package com.pm.service.file.impl;

import com.pm.entity.po.file.DailyNewsType;
import com.pm.entity.vo.dept.DailyNewsTypeVo;
import com.pm.mapper.file.DailyNewsMapper;
import com.pm.mapper.file.DailyNewsTypeMapper;
import com.pm.service.file.DailyNewsTypeService;
import com.pm.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DailyNewsTypeServiceImpl extends BaseServiceImpl<DailyNewsType> implements DailyNewsTypeService {
    @Autowired
    DailyNewsTypeMapper dailyNewsTypeMapper;
    @Autowired
    DailyNewsMapper dailyFileLibMapper;

    @Resource
    private void setBaseMapper(DailyNewsTypeMapper dailyNewsTypeMapper) {
        super.setBaseMapper(dailyNewsTypeMapper);
    }

    @Override
    public DailyNewsTypeVo getListDailyNewsType(DailyNewsType dailyNewsType) {
        DailyNewsTypeVo dailyNewsTypeVos = new DailyNewsTypeVo();
        if (dailyNewsType.getParentId() == null) {
            List<DailyNewsType> dailyNewsTypesOne = dailyNewsTypeMapper.getListType(dailyNewsType);
            //List<DailyNews> dailyFileLibOne = dailyFileLibMapper.getList(null);
            // 文件夹
            dailyNewsTypeVos.setDailyNewsTypes(dailyNewsTypesOne);
            //dailyNewsTypeVos.setDailyNews(dailyFileLibOne);
            dailyNewsTypeVos.setFatherId(null);
            return dailyNewsTypeVos;
        } else {
            List<DailyNewsType> dailyNewsTypesOne = null;
            // 文件夹
            dailyNewsTypesOne = dailyNewsTypeMapper.getListDailyNewsType(dailyNewsType);
            //List<DailyNews> dailyFileLibs = dailyFileLibMapper.getList(dailyNewsType.getParentId());
            dailyNewsTypeVos.setDailyNewsTypes(dailyNewsTypesOne);
            //dailyNewsTypeVos.setDailyNews(dailyFileLibs);
            dailyNewsTypeVos.setFatherId(dailyNewsTypeMapper.getFatherId(dailyNewsType.getParentId()));
            dailyNewsTypeVos.setParentIdNew(dailyNewsTypeMapper.getParentIdNew(dailyNewsType.getParentId()));
            return dailyNewsTypeVos;
        }

    }
}
